//
//  ViewExpenseViewController.m
//  Wallets Manager
//
//  Created by Tung Nguyen on 10/21/12.
//  Copyright (c) 2012 BKHN. All rights reserved.
//

#import "ViewExpenseViewController.h"

@interface ViewExpenseViewController ()

@end

@implementation ViewExpenseViewController
@synthesize currentExpense;
@synthesize scrollView;
@synthesize expenseNameTextField;
@synthesize categoryImageView;
@synthesize categoryTextField;
@synthesize amountTextField;
@synthesize dateTextField;
@synthesize walletTextField;
@synthesize planImageView;
@synthesize planTextField;
@synthesize noteTextField;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    folyAppDelegate *delegate = [[UIApplication sharedApplication]delegate];
    walletTextField.text = delegate.currentWallet.w_name;
    
    scrollView.contentSize = CGSizeMake(320, 400);
    
    expenseNameTextField.text = currentExpense.e_name;
    
    categoryTextField.text = currentExpense.eToExpenseType.et_name;
    [categoryImageView setImage:[UIImage imageNamed:currentExpense.eToExpenseType.et_image]];
    
    amountTextField.text = [NSString stringWithFormat:@"%d",[currentExpense.e_amount intValue]];
    
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
    [dateFormatter setDateFormat:@"MM/dd/yyyy"];
    dateTextField.text = [dateFormatter stringFromDate:currentExpense.e_date];
    
    
    planTextField.text = currentExpense.eToPlan.p_name;
    [planImageView setImage:[UIImage imageNamed:currentExpense.eToPlan.p_image]];
    
    noteTextField.text = currentExpense.e_notes;

    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [self setExpenseNameTextField:nil];
    [self setCategoryImageView:nil];
    [self setCategoryTextField:nil];
    [self setAmountTextField:nil];
    [self setDateTextField:nil];
    [self setWalletTextField:nil];
    [self setPlanImageView:nil];
    [self setPlanTextField:nil];
    [self setNoteTextField:nil];
    [self setScrollView:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (IBAction)backButtonPressed:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
@end
